const http = require("http");
const server = http.createServer(function (req, res) {
    const fs = require("fs");
    let arr = fs.readdirSync("../homework");
    res.setHeader("Content-Type", "text/html;charset=utf-8");
    res.write("<table><tr><th>文件名</th><th>操作</th></tr>");
    for (const iterator of arr) {
        let stat = fs.statSync(iterator);
        if (stat.isFile()) {
            res.write("<tr><td>" + iterator + "</td><td>删除</td></tr>");
        } else {
            res.write("<tr><td><a href='#'>" + iterator + "</a></td><td>删除</td></tr>");
        }
    }
    res.write("</table>");
    res.end();
})

server.listen(8888);